package tp4.dsl.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import tp4.dsl.pdm.ADictar;
import tp4.dsl.pdm.Asignacion;
import tp4.dsl.pdm.Aula;
import tp4.dsl.pdm.Exclusivo;
import tp4.dsl.pdm.Horario;
import tp4.dsl.pdm.HorarioXDia;
import tp4.dsl.pdm.Materia;
import tp4.dsl.pdm.Model;
import tp4.dsl.pdm.PdmPackage;
import tp4.dsl.pdm.Planificacion;
import tp4.dsl.pdm.Profesor;
import tp4.dsl.pdm.Requerimiento;
import tp4.dsl.pdm.Semi;
import tp4.dsl.pdm.Simple;
import tp4.dsl.services.PdmGrammarAccess;

@SuppressWarnings("all")
public class PdmSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private PdmGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == PdmPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case PdmPackage.ADICTAR:
				if(context == grammarAccess.getADictarRule()) {
					sequence_ADictar(context, (ADictar) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.ASIGNACION:
				if(context == grammarAccess.getAsignacionRule()) {
					sequence_Asignacion(context, (Asignacion) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.AULA:
				if(context == grammarAccess.getAulaRule()) {
					sequence_Aula(context, (Aula) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.EXCLUSIVO:
				if(context == grammarAccess.getDedicacionRule() ||
				   context == grammarAccess.getExclusivoRule()) {
					sequence_Exclusivo(context, (Exclusivo) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.HORARIO:
				if(context == grammarAccess.getHorarioRule()) {
					sequence_Horario(context, (Horario) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.HORARIO_XDIA:
				if(context == grammarAccess.getHorarioXDiaRule()) {
					sequence_HorarioXDia(context, (HorarioXDia) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.MATERIA:
				if(context == grammarAccess.getMateriaRule()) {
					sequence_Materia(context, (Materia) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.MODEL:
				if(context == grammarAccess.getModelRule()) {
					sequence_Model(context, (Model) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.PLANIFICACION:
				if(context == grammarAccess.getPlanificacionRule()) {
					sequence_Planificacion(context, (Planificacion) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.PROFESOR:
				if(context == grammarAccess.getProfesorRule()) {
					sequence_Profesor(context, (Profesor) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.REQUERIMIENTO:
				if(context == grammarAccess.getRequerimientoRule()) {
					sequence_Requerimiento(context, (Requerimiento) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.SEMI:
				if(context == grammarAccess.getDedicacionRule() ||
				   context == grammarAccess.getSemiRule()) {
					sequence_Semi(context, (Semi) semanticObject); 
					return; 
				}
				else break;
			case PdmPackage.SIMPLE:
				if(context == grammarAccess.getDedicacionRule() ||
				   context == grammarAccess.getSimpleRule()) {
					sequence_Simple(context, (Simple) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (materia=[Materia|ID] inscriptos=INT)
	 */
	protected void sequence_ADictar(EObject context, ADictar semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.ADICTAR__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.ADICTAR__MATERIA));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.ADICTAR__INSCRIPTOS) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.ADICTAR__INSCRIPTOS));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getADictarAccess().getMateriaMateriaIDTerminalRuleCall_0_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getADictarAccess().getInscriptosINTTerminalRuleCall_2_0(), semanticObject.getInscriptos());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (materia=[Materia|ID] profesor=[Profesor|ID])
	 */
	protected void sequence_Asignacion(EObject context, Asignacion semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.ASIGNACION__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.ASIGNACION__MATERIA));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.ASIGNACION__PROFESOR) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.ASIGNACION__PROFESOR));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getAsignacionAccess().getMateriaMateriaIDTerminalRuleCall_1_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getAsignacionAccess().getProfesorProfesorIDTerminalRuleCall_3_0_1(), semanticObject.getProfesor());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID capacidadAula=INT (requerimientos+=[Requerimiento|ID] requerimientos+=[Requerimiento|ID]*)?)
	 */
	protected void sequence_Aula(EObject context, Aula semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     {Exclusivo}
	 */
	protected void sequence_Exclusivo(EObject context, Exclusivo semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (dia=Dia horarios+=Horario*)
	 */
	protected void sequence_HorarioXDia(EObject context, HorarioXDia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (horaInicio=INT horaFin=INT materia=[Materia|ID] aula=[Aula|ID])
	 */
	protected void sequence_Horario(EObject context, Horario semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.HORARIO__HORA_INICIO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.HORARIO__HORA_INICIO));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.HORARIO__HORA_FIN) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.HORARIO__HORA_FIN));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.HORARIO__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.HORARIO__MATERIA));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.HORARIO__AULA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.HORARIO__AULA));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getHorarioAccess().getHoraInicioINTTerminalRuleCall_0_0(), semanticObject.getHoraInicio());
		feeder.accept(grammarAccess.getHorarioAccess().getHoraFinINTTerminalRuleCall_2_0(), semanticObject.getHoraFin());
		feeder.accept(grammarAccess.getHorarioAccess().getMateriaMateriaIDTerminalRuleCall_3_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getHorarioAccess().getAulaAulaIDTerminalRuleCall_5_0_1(), semanticObject.getAula());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID diasEnLaSemana=INT cargaHoraria=INT (requerimientos+=[Requerimiento|ID] requerimientos+=[Requerimiento|ID]*)?)
	 */
	protected void sequence_Materia(EObject context, Materia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (requerimientosACargar+=Requerimiento* profesoresACargar+=Profesor* materiasACargar+=Materia* aulasACargar+=Aula* planificacion=Planificacion)
	 */
	protected void sequence_Model(EObject context, Model semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (anio=INT semestre=INT materiasADictar+=ADictar* horariosXDia+=HorarioXDia* asignaciones+=Asignacion*)
	 */
	protected void sequence_Planificacion(EObject context, Planificacion semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID dedicacion=Dedicacion)
	 */
	protected void sequence_Profesor(EObject context, Profesor semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.PROFESOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.PROFESOR__NAME));
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.PROFESOR__DEDICACION) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.PROFESOR__DEDICACION));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getProfesorAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getProfesorAccess().getDedicacionDedicacionParserRuleCall_3_0(), semanticObject.getDedicacion());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_Requerimiento(EObject context, Requerimiento semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PdmPackage.Literals.REQUERIMIENTO__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PdmPackage.Literals.REQUERIMIENTO__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getRequerimientoAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     {Semi}
	 */
	protected void sequence_Semi(EObject context, Semi semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     {Simple}
	 */
	protected void sequence_Simple(EObject context, Simple semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
